import { ref } from 'vue'
import { defineStore } from 'pinia'

export const Button_Store = defineStore('anniu_info', () => {
    const zhedie_status = ref(false)
    const zhedie_text = ref('折叠侧边栏') 
    const zhedie_width = ref('13vw')
    const side_title = ref('系统管理后台')

    const set_zhedie_button = () => {
        if(zhedie_status.value == false){
            zhedie_status.value = true
            zhedie_text.value = "展开侧边栏"
            zhedie_width.value = "64px"
            side_title.value = "—>"
        }else{
            zhedie_status.value = false
            zhedie_text.value = "折叠侧边栏"
            zhedie_width.value = "13vw"
            side_title.value = "系统管理后台"
        } 
    }



    const tabs_list = ref([
            {   
                route: '/jiazi/shouye',
                title: '首页',
                name: '首页',
                component: 'shouye',
            },
            {
                route: '/jiazi/service',
                title: '服务性能',
                name: '服务性能',
                component: 'service',
            },
            {
                route: '/jiazi/user_manager',
                title: '用户管理',
                name: '用户管理',
                component: 'user_manager',
            },
            {
                route: '/jiazi/role',
                title: '角色管理',
                name: '角色管理',
                component: 'role',
            },
            {
                route: '/jiazi/menu',
                title: '菜单管理',
                name: '菜单管理',
                component: 'menu',
            },
            {
                route: '/jiazi/department',
                title: '部门管理',
                name: '部门管理',
                component: 'department',
            },
            {
                route: '/jiazi/position',
                title: '岗位管理',
                name: '岗位管理',
                component: 'position',
            },
            
        ])

    const new_tabs_list = ref([
            {   
                route: '/jiazi/shouye',
                title: '首页',
                name: '首页',
                component: 'shouye'
            }
        ])    
    const now_tab = ref('首页') 


    const set_tabs_list = (aside_data) => {
        let my_item = tabs_list.value.find(item => item.route === aside_data)
        now_tab.value = my_item.name
        if(!new_tabs_list.value.some(tab => tab.route === aside_data)){
            new_tabs_list.value.push(my_item)
        }
    }

    const tabs_list_back = () => {
        new_tabs_list.value = [
            {   
                route: '/jiazi/shouye',
                title: '首页',
                name: '首页',
                component: 'shouye'
            }
        ]
        now_tab.value = '首页'
    }



  return {
    zhedie_status,
    zhedie_text,
    zhedie_width,
    side_title,
    new_tabs_list,
    now_tab,
    tabs_list,
    set_tabs_list,
    set_zhedie_button,
    tabs_list_back
     }
},
 {
    persist:true
  }  
)
